package com.sharemarking.wa.platform.mapper;

import com.sharemarking.wa.common.entity.Car;
import com.sharemarking.wa.platform.dto.carManagement.CarListDto;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author dxy
 */
@Repository
public interface CarManagementMapper {
    @Select("SELECT a.id,type,number,car_weight,driver_id," +
            "(SELECT name FROM wa_driver_verify c WHERE c.member_id = driver_id) driverName" +
            " FROM wa_org_car a LEFT JOIN sys_org_member b ON a.org_id = b.org_id WHERE b.member_id = #{memberId} LIMIT #{pageIndex},#{pageSize}")
    List<CarListDto> getList(Map map);

    @Select("SELECT COUNT(*) FROM wa_org_car a LEFT JOIN sys_org_member b ON a.org_id = b.org_id WHERE b.member_id = #{memberId}" )
    Integer getListTotal(Map map);

    @Select("select * from wa_org_car where number = #{number}")
    Car getCarInfo(String number);

    @Select("select * from wa_org_car where driver_id = #{driverId}")
    Car getCarInfoByDriverId(int driverId);

}
